package com.fdsc.erp.weixin;

import com.fdsc.erp.weixin.Menu.*;
import com.fdsc.erp.weixin.Utils.CommonUtil;
import com.fdsc.erp.weixin.Utils.Token;

/**
 * @Description:创建菜单
 * @Author:lishanhui
 * @Date:Create in 13:12  2018-06-06
 **/
public class MenuManager {
    public static void main(String[] args) {
        //调用接口获取token
        Token token = CommonUtil.getToken();
        if (token != null) {
            //创建菜单
            boolean result = MenuUtil.makeMenu(makeMenuXml(), token.getAccessToken());
            //查询菜单
//            boolean result = MenuUtil.selectMenu(token.getAccessToken());
            //删除菜单
//            boolean result = MenuUtil.delectMenu(token.getAccessToken());
        }
    }

    /**
     * @Date:Create in 13:21 2018-06-06
     * @Description:创建菜单xml数据
     * @params: * @param null
     * @return:
     **/
    private static Menu makeMenuXml() {
        ViewButton btn1 = new ViewButton();
        btn1.setName("同学风采");
        btn1.setType("view");
        btn1.setUrl("https://shop42433089.youzan.com/v2/home/JpaBObg33b?reft=1553481988049&spm=g.457014279&sf=wx_sm&is_share=1&from=singlemessage&isappinstalled=0&redirect_count=1");

        ViewButton btn21 = new ViewButton();
        btn21.setName("我要加入");
        btn21.setType("view");
        btn21.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa7128e4fafdaeb0e&redirect_uri=http%3A%2F%2Feh.sjmoban.com%2Ferp%2Fquestionnaire%2FgetWeixinUUid&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
//        eh.sjmoban.com/erp/questionnaire/getWeixinUUid
        ViewButton btn22 = new ViewButton();
        btn22.setName("同学录");
        btn22.setType("view");
        btn22.setUrl("http://eh.sjmoban.com/erp/modules/alumniBook.html");

        ViewButton btn23 = new ViewButton();
        btn23.setName("绑定修改");
        btn23.setType("view");
        btn23.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa7128e4fafdaeb0e&redirect_uri=http%3A%2F%2Feh.sjmoban.com%2Ferp%2Fquestionnaire%2FgetWeixinUUidToEdit&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");

        ComplexButton btn2 = new ComplexButton();
        btn2.setName("同学会");
        btn2.setSub_button(new Button[]{btn21, btn22,btn23});

        ViewButton btn3 = new ViewButton();
        btn3.setName("财务");
        btn3.setType("view");
        btn3.setUrl("http://eh.sjmoban.com/erp/modules/finance.html");

       /* ViewButton btn2 = new ViewButton();
        btn2.setName("授权");
        btn2.setType("view");
        btn2.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx806a2066a013e25e&redirect_uri=http%3A%2F%2F47.105.89.196%2Fquestionnaire%2FgetWeixinUUid&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");

        ClickButton btn31 = new ClickButton();
        btn31.setName("Hello World");
        btn31.setType("click");
        btn31.setKey("V1001_1");

        ClickButton btn32 = new ClickButton();
        btn32.setName("赞");
        btn32.setType("click");
        btn32.setKey("V1001_2");

        ComplexButton btn3 = new ComplexButton();
        btn3.setName("菜单");
        btn3.setSub_button(new Button[]{btn31, btn32});*/

        //创建菜单对象
        Menu menu = new Menu();
        menu.setButton(new Button[]{btn1, btn2, btn3});

        return menu;
    }
}
